package com.huike;

import com.huike.clues.service.ITbActivityService;
import com.huike.clues.service.impl.SysDictTypeServiceImpl;
import org.aopalliance.aop.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.servlet.Filter;
import java.io.IOException;
import java.util.Map;

/**
 * 启动程序
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableScheduling
public class HuiKeApplication implements CommandLineRunner {

    @Autowired
    private ITbActivityService activityService;


    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(HuiKeApplication.class, args);
//        Map<String, Filter> filters = context.getBeansOfType(Filter.class);
//        filters.keySet().forEach(k -> System.out.println(k + " -- " + filters.get(k)));
        // BeanPostProcessor
//        Map<String, BeanPostProcessor> beanPostProcessorMap = context.getBeansOfType(BeanPostProcessor.class);
//        beanPostProcessorMap.keySet().stream().forEach(k -> System.out.println( k + " -- "+ beanPostProcessorMap.get(k)));

        /*
jwtAuthenticationTokenFilter -- com.huike.framework.security.filter.JwtAuthenticationTokenFilter@31120021
corsFilter -- org.springframework.web.filter.CorsFilter@6a1d6ef2
requestContextFilter -- org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter@6bee793f
formContentFilter -- org.springframework.boot.web.servlet.filter.OrderedFormContentFilter@40d23c82
springSecurityFilterChain -- FilterChainProxy[Filter Chains: [[ any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@fee881, org.springframework.security.web.context.SecurityContextPersistenceFilter@6b091a92, org.springframework.security.web.header.HeaderWriterFilter@e7b0bec, org.springframework.web.filter.CorsFilter@6a1d6ef2, org.springframework.web.filter.CorsFilter@6a1d6ef2, org.springframework.security.web.authentication.logout.LogoutFilter@3b7b0b57, com.huike.framework.security.filter.JwtAuthenticationTokenFilter@31120021, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@21a5b599, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@1cc93da4, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@1ff463bb, org.springframework.security.web.session.SessionManagementFilter@30228de7, org.springframework.security.web.access.ExceptionTranslationFilter@1ad1b737, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5b3755f4]]]]
characterEncodingFilter -- org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter@594d9f07
        * */
    }

    @Override
    public void run(String... args) {
        try {
            //加载所有活动code到缓存
            activityService.loadAllActivityCode();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

